package com.zj.core.ui

import android.content.Context
import android.support.v7.widget.RecyclerView
import android.view.View
import android.view.ViewManager
import android.widget.LinearLayout
import com.scwang.smartrefresh.layout.SmartRefreshLayout
import com.zj.core.R
import org.jetbrains.anko.*
import org.jetbrains.anko.custom.ankoView

class NurseListUi(groupView: LinearLayout): AnkoComponent<Context> {
    private var view: LinearLayout =groupView
    var refreshLayout:SmartRefreshLayout?=null
    var list_record_view:RecyclerView?=null

    override fun createView(ui: AnkoContext<Context>): View =with(view){
        linearLayout{
            lparams(width= matchParent,height= matchParent)

            refreshLayout=smartRefreshLayout{
                layoutParams=LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT)
                id=R.id.refreshLayout

                list_record_view=recyclerview{
                    layoutParams=LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT)
                    id=R.id.list_nurse_record_view
                    backgroundColor=resources.getColor(R.color.colorsFrenchWhite)
                    setPadding(dip(15),0,dip(15),0)
                }
            }
        }
    }

    inline fun ViewManager.recyclerview(theme: Int = 0, init: RecyclerView.() -> Unit) : RecyclerView {
        return ankoView({ RecyclerView(it) }, theme, init)
    }

    inline fun ViewManager.smartRefreshLayout(theme: Int = 0, init: SmartRefreshLayout.() -> Unit) : SmartRefreshLayout {
        return ankoView({ SmartRefreshLayout(it) }, theme, init)
    }
}